home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / htmlparser / nsIDTD.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  223 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsIDTD_h___
  39. #define nsIDTD_h___
  40.  
  41. /**
  42.  * MODULE NOTES:
  43.  * @update  gess 7/20/98
  44.  *
  45.  * This interface defines standard interface for DTD's. Note that this
  46.  * isn't HTML specific. DTD's have several functions within the parser
  47.  * system:
  48.  *      1) To coordinate the consumption of an input stream via the
  49.  *      parser
  50.  *      2) To serve as proxy to represent the containment rules of the
  51.  *      underlying document
  52.  *      3) To offer autodetection services to the parser (mainly for doc
  53.  *      conversion)
  54.  * */
  55.  
  56. #include "nsISupports.h"
  57. #include "nsString.h"
  58. #include "prtypes.h"
  59. #include "nsITokenizer.h"
  60.  
  61. #define NS_IDTD_IID \
  62.  { 0xa6cf9053, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
  63.  
  64. enum eAutoDetectResult {
  65.     eUnknownDetect,
  66.     eValidDetect,
  67.     ePrimaryDetect,
  68.     eInvalidDetect
  69. };
  70.  
  71. enum nsDTDMode {
  72.     eDTDMode_unknown = 0,
  73.     eDTDMode_quirks,        //pre 4.0 versions
  74.     eDTDMode_almost_standards,
  75.     eDTDMode_full_standards,
  76.     eDTDMode_autodetect,
  77.     eDTDMode_fragment
  78. };
  79.  
  80.  
  81. class nsIParser;
  82. class CToken;
  83. class nsIURI;
  84. class nsIContentSink;
  85. class CParserContext;
  86.  
  87. class nsIDTD : public nsISupports
  88. {
  89. public:
  90.  
  91.     NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDTD_IID)
  92.  
  93.  
  94.     NS_IMETHOD_(const nsIID&) GetMostDerivedIID(void) const = 0;
  95.  
  96.     /**
  97.      * Call this method if you want the DTD to construct a clone of itself.
  98.      * @update  gess7/23/98
  99.      * @param
  100.      * @return
  101.      */
  102.     NS_IMETHOD CreateNewInstance(nsIDTD** aInstancePtrResult) = 0;
  103.  
  104.     /**
  105.      * This method is called to determine if the given DTD can parse
  106.      * a document in a given source-type.
  107.      * NOTE: Parsing always assumes that the end result will involve
  108.      *       storing the result in the main content model.
  109.      * @param aParserContext -- the context for this document (knows
  110.      *           the content type, document type, parser command, etc).
  111.      * @return eUnknownDetect if you don't know how to parse it,
  112.      *         eValidDetect if you do, but someone may have a better idea,
  113.      *         ePrimaryDetect if you think you know best
  114.      */
  115.     NS_IMETHOD_(eAutoDetectResult) CanParse(CParserContext& aParserContext) = 0;
  116.  
  117.     NS_IMETHOD WillBuildModel(const CParserContext& aParserContext,
  118.                               nsITokenizer* aTokenizer,
  119.                               nsIContentSink* aSink) = 0;
  120.  
  121.     /**
  122.      * Called by the parser after the parsing process has concluded
  123.      * @update  gess5/18/98
  124.      * @param   anErrorCode - contains error code resulting from parse process
  125.      * @return
  126.      */
  127.     NS_IMETHOD DidBuildModel(nsresult anErrorCode, PRBool aNotifySink,
  128.                              nsIParser* aParser,
  129.                              nsIContentSink* aSink) = 0;
  130.  
  131.     /**
  132.      * Called by the parser after the parsing process has concluded
  133.      * @update  gess5/18/98
  134.      * @param   anErrorCode - contains error code resulting from parse process
  135.      * @return
  136.      */
  137.     NS_IMETHOD BuildModel(nsIParser* aParser, nsITokenizer* aTokenizer,
  138.                           nsITokenObserver* anObserver,
  139.                           nsIContentSink* aSink) = 0;
  140.  
  141.     /**
  142.      * Called during model building phase of parse process. Each token
  143.      * created during the parse phase is stored in a deque (in the
  144.      * parser) and are passed to this method so that the DTD can
  145.      * process the token. Ultimately, the DTD will transform given
  146.      * token into calls onto a contentsink.
  147.      * @update  gess 3/25/98
  148.      * @param   aToken -- token object to be put into content model
  149.      * @return error code (usually 0)
  150.      */
  151.     NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser) = 0;
  152.  
  153.     /**
  154.      * If the parse process gets interrupted midway, this method is
  155.      * called by the parser prior to resuming the process.
  156.      * @update  gess5/18/98
  157.      * @return ignored
  158.      */
  159.     NS_IMETHOD WillResumeParse(nsIContentSink* aSink) = 0;
  160.  
  161.     /**
  162.      * If the parse process gets interrupted, this method is called by
  163.      * the parser to notify the DTD that interruption will occur.
  164.      * @update  gess5/18/98
  165.      * @return ignored
  166.      */
  167.     NS_IMETHOD WillInterruptParse(nsIContentSink* aSink) = 0;
  168.  
  169.     /**
  170.      * This method is called to determine whether or not a tag of one
  171.      * type can contain a tag of another type.
  172.      *
  173.      * @update  gess 3/25/98
  174.      * @param   aParent -- int tag of parent container
  175.      * @param   aChild -- int tag of child container
  176.      * @return PR_TRUE if parent can contain child
  177.      */
  178.     NS_IMETHOD_(PRBool) CanContain(PRInt32 aParent,PRInt32 aChild) const = 0;
  179.  
  180.     /**
  181.      * This method gets called to determine whether a given
  182.      * tag is itself a container
  183.      *
  184.      * @update  gess 3/25/98
  185.      * @param   aTag -- tag to test for containership
  186.      * @return  PR_TRUE if given tag can contain other tags
  187.      */
  188.     NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const = 0;
  189.  
  190.     /**
  191.      * Use this id you want to stop the building content model
  192.      * --------------[ Sets DTD to STOP mode ]----------------
  193.      * It's recommended to use this method in accordance with
  194.      * the parser's terminate() method.
  195.      *
  196.      * @update  harishd 07/22/99
  197.      * @param
  198.      * @return
  199.      */
  200.     NS_IMETHOD_(void) Terminate() = 0;
  201.  
  202.     NS_IMETHOD_(PRInt32) GetType() = 0;
  203.  
  204.     NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo) = 0;
  205. };
  206.  
  207. #define NS_DECL_NSIDTD \
  208.     NS_IMETHOD_(const nsIID&)  GetMostDerivedIID(void) const;\
  209.     NS_IMETHOD CreateNewInstance(nsIDTD** aInstancePtrResult);\
  210.     NS_IMETHOD_(eAutoDetectResult) CanParse(CParserContext& aParserContext);\
  211.     NS_IMETHOD WillBuildModel(  const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\
  212.     NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink);\
  213.     NS_IMETHOD BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink);\
  214.     NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);\
  215.     NS_IMETHOD WillResumeParse(nsIContentSink* aSink = 0);\
  216.     NS_IMETHOD WillInterruptParse(nsIContentSink* aSink = 0);\
  217.     NS_IMETHOD_(PRBool) CanContain(PRInt32 aParent,PRInt32 aChild) const;\
  218.     NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const;\
  219.     NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo);\
  220.     NS_IMETHOD_(void)  Terminate();\
  221.     NS_IMETHOD_(PRInt32) GetType();
  222. #endif /* nsIDTD_h___ */
  223.